package com.szrt.ms.manager;

import java.util.Scanner;

import com.szrt.ms.entity.StudentEntity;

public class BanJi {
	
	static{
		
		Scanner sc=new Scanner(System.in);
	}
	
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		System.out.println("输入班级人数：");
		int len=sc.nextInt();
		BanJi1612 bj=new BanJi1612(len);
		StudentEntity stu=new StudentEntity();
		int index=0;
		while(true){
			System.out.println("请输入第"+(index+1)+"要添加的学生的姓名");
			String name = sc.next();
			if(name.equals("quit")){
				break;
			}
			stu.setName(name);
			
			System.out.println("请输入第"+(index+1)+"要添加的学生的年龄");
			int age=sc.nextInt();
			stu.setAge(age);
			
			System.out.println("请输入第"+(index+1)+"要添加的学生的性别");
			char sex=sc.next().charAt(0);
			stu.setSex(sex);
			
			System.out.println("请输入第"+(index+1)+"要添加的学生的分数");
			double score=sc.nextDouble();
			stu.setScore(score);
			System.out.println("请输入第"+(index+1)+"要添加的学生的城市");
			String city=sc.next();
			stu.setCity(city);
		
			bj.add(stu);
			index++;
			
		}
		StudentEntity[] students = bj.getStudents();
		
		while(true){
			System.out.println("===================================================");
			System.out.println();
			System.out.println();
			System.out.println("1.修改学生  ");
			System.out.println("2.最高分  ");
			System.out.println("3.最小成绩  ");
			System.out.println("4.计算性别的个数  ");
			System.out.println("5.计算男女的个数  ");
			System.out.println("6.有几个今年是本命年?  ");
			System.out.println("7.删除1个学生  ");
			System.out.println("8.查看在本班我有几个老乡  ");
			System.out.println("9.查看在本班我有几个老乡 都是谁  ");
			System.out.println("10.一次性删除多个学生  ");
			System.out.println("11.退出  ");
			System.out.println();
			System.out.println();
			System.out.println("===================================================");
			int select=sc.nextInt();
			if(1==select){
				
				System.out.println("要修改的学生的名字");
				String name=sc.next();
				System.out.println("要修改的学生的分数");
				double score=sc.nextDouble();
				bj.update(name,score);
				
				for (StudentEntity va : students) {
					System.out.println(va);
				}
				
			}else if(2==select){
				
				bj.searchScoreMax();
				
			}else if(3==select){
				
				bj.searchScoreMin();
				
			}else if(4==select){
				
				System.out.println("要查找的性别");
				char sex=sc.next().charAt(0);
				int nub=bj.getNumberOfMales(sex);
				
				System.out.println(sex+"的个数："+nub);
				
			}else if(5==select){
				
				int[] nub =new int[2];
				
				nub = bj.getxb();
				nub = bj.getxb();
				System.out.println("男生的个数："+nub[0]);
				System.out.println("女生的个数："+nub[1]);
				
			}else if(6==select){
				
				int cou=bj.benMingNian();
				System.out.println("今年是本命年有:"+cou+"个");
			}else if(7==select){
				
				System.out.println("要删除的学生的名字");
				String name=sc.next();
				bj.deleteOne(name);
				
				for (StudentEntity st : students) {
					System.out.println(st);
				}
			}else if(8==select){
				
				System.out.println("输入你的名字");
				String name=sc.next();
				int counter=bj.findLX(name);
				System.out.println("老乡的个数有："+(counter-1));
			}else if(9==select){
				
				System.out.println("输入你的名字");
				String name=sc.next();
				StudentEntity[] lx=bj.findLXDetail(name);
				
				for (StudentEntity tx : lx) {
					System.out.println(tx);
				}
			}else if(10==select){
				
				System.out.println("要删除几个学生");
				int l=sc.nextInt();
				String[] names=new String[l];
				System.out.println("要删除多个学生的名字，名字间换行");
				for(int i=0;i<l;i++){
					names[i]=sc.next();
				}
				
				bj.deleteMuchStudentByNames(names);
				
				for (StudentEntity st : students) {
					System.out.println(st);
				}
				
			}else if(11==select){
				System.out.println("成功退出");
				break;
			}
			
		}
		
		sc.close();
		
	}

}
